package com.snopy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.websocket.server.PathParam;
import java.util.Map;

/**
 * TODO
 *
 * @author snoopy
 * @date 2020/9/18 0018 23:14
 * @email 77912204@qq.com
 * @remark
 */
@ApiIgnore
@RestController
public class HelloConroller {
    @Autowired
    private RedisTemplate redisTemplate;
    @PostMapping("/hello")
    public Object hello(){
        System.out.printf("hello");
        return "Hello World~";
    }
    @PostMapping("/set")
    public void set(@PathParam("key") String key, @PathParam("val")String val){
        redisTemplate.opsForValue().set(key,val);
    }
    @PostMapping("/get")
    public String get(@PathParam("key") String key){
       return (String) redisTemplate.opsForValue().get(key);
    }
    @GetMapping("/test")
    public String test(@PathParam("param") String param){
        System.out.println(param);
        return (String) redisTemplate.opsForValue().get(param);
    }
}
